
#include "user_extern.h"

/* 全局变量 OLED刷新缓存 */
uint8_t OLED_GRAM[X_WIDTH][PAGE];            //oled_gram

/* 全局变量 窗口管理器 */
Windows *windows;
System_Api Dsystem;

esp_err_t delay_ms(uint32_t time)
{
    vTaskDelay(time / portTICK_RATE_MS);
    return ESP_OK;
}

void display_the_scream(void)
{
    if (windows[Dsystem.windows_cur_id].win_status == WINDOWS_STATUS_NONE)
    {
        oled.refresh_all(1);
    }
}

void app_main(void)
{
    int id = 999;
    memset(OLED_GRAM, 0, sizeof(OLED_GRAM));
    module_init();
    system_show_splash();
    init_windows();
    system_init();
    digimon_init(0);    
    //oled.clean_gram(0x00);
    while (1)
    {
        //tone.button_tone();
        if(Dsystem.windows_cur_id != id)
        {
            id = Dsystem.windows_cur_id;
        }
        windows[id].run();
        windows[id].update_screen();
        delay_ms(Dsystem.ui_frame_time);
    }
}
